<?php
namespace App\Http\utils;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
trait trashedMethods{
    //批量删除
    public function deleteChecked(Request $request){
        if(!$request->has('id')){
            return json(101,'无已选');
        }
        $id=explode(',',$request->input('id'));
        $menu=DB::table(self::$tableName)->whereIn('id',$id)->update(['deleted_at'=>Date('y-m-d h-i-s')]);
        return json(200,'删除已选成功');
    }

    //软删除恢复
    public function restoreChecked(Request $request){
        if(!$request->has('id')){
            return json(101,'无已选');
        }
        $id=explode(',',$request->input('id'));
        $menu=DB::table(self::$tableName)->whereIn('id',$id)->update(['deleted_at'=>null]);
        return json(200,'恢复已选成功');
    }

    //彻底删除
    public function forceDeleteChecked(Request $request){
        if(!$request->has('id')){
            return json(101,'无已选');
        }
        $id=explode(',',$request->input('id'));
        $menu=DB::table(self::$tableName)->whereIn('id',$id)->delete();
        return json(200,'删除已选成功');
    }
}